<?php
	include_once('include/db_connect.php');
	include_once('include/admindb.php');
	$COM="users";
	require_once('include/toolbar.php');
	
	if(isset($_POST['cmd'])){ //add hoặc edit
		$AUserName = htmlspecialchars(addslashes($_POST['txt_User']));
		$APassword = md5(addslashes($_POST['txt_Password']));
		$AAddress = htmlspecialchars($_POST['txt_Add']);
		$AEmail = htmlspecialchars($_POST['txt_Email']);
		$APhone = htmlspecialchars($_POST['txt_Phone']);
		$AFullName = htmlspecialchars($_POST['txt_Name']);
		$Level = $_POST['seQuyen'];
		$isActive = $_POST['opt_active'];
		
		if(isset($_POST['txt_id'])){
			$id = $_POST['txt_id'];
			Edit($id,$AUserName,$AAddress,$AEmail,$APhone,$AFullName,$Level,$isActive);
		}
		else{
			Add($AUserName,$APassword,$AAddress,$AEmail,$APhone,$AFullName,$Level,$isActive);
		}
		header('location:index.php?page='.$COM);
	}
	
	if($_SESSION['Level'] ==0){
   $task="";
if(isset($_GET['task']))
	$task=$_GET['task'];
//$thistask='components/com_users'.'/';
$thistask = $COM_PATH.'com_'.$COM.'/';
if(!is_file($thistask.$task.'.php'))
	$task='list';
include($thistask.$task.'.php');
}	else echo 'mày không có quyền';
?>